package day04;
import java.util.Scanner;
import  java.util.Arrays;
public class Practice01 {
    public static void main(String[] args) {
        //1.Addition随机加法运算器
        //要求：由系统随机出10道加法题，而后由用户来答题，答题后输出"答对了"或"答错了"，答对1题得10分，答错1题不扣分，最后输出总分数。
        Scanner scan = new Scanner(System.in);
        int score = 0;
        for (int a = 1; a <= 10; a++) {
            int a1 = (int) (Math.random() * 1000);
            int a2 = (int) (Math.random() * 1000);
            System.out.println("请计算" + a1 + "+" + a2 + "=?");
            if (a1 + a2 == scan.nextInt()) {
                System.out.println("答对了，+10分");
                score += 10;
            } else {
                System.out.println("答错了，别灰心");
            }
        }
        System.out.println("你的总分为：" + score);

        //2.MultiTable九九乘法表
        //要求：输出九九乘法表
        int b1 = 0;
        for (; b1 <= 9; b1++) {
            for (int b2 = 0; b2 <= b1; b2++) {
                System.out.print(b1 + "*" + b2 + "=" + b1 * b2 + "\t");
            }
            System.out.println();
        }

        //3.数组小代码练习：声明、初始化、访问、遍历
        int[] c = new int[2];//声明
        c = new int[]{6, 9};//初始化
        System.out.println(c.length);
        System.out.println(c[0]);//访问
        System.out.println(c[1]);
        for (int c_num = 0; c_num < c.length; c_num++) {//遍历
            System.out.println(c[c_num]);
        }

        //4.MaxOfArray求数组元素最大值
        int max = c[0];
        for (int d = 1; d < c.length; d++) {
            if (c[d] > max) {
                max = c[d];
            }
        }
        System.out.println("最大值为：" + max);


        //5.对数组进行升序排列，并输出排序后的结果
        int[]arr = new int[10];
        for (int e=0;e<arr.length;e++){
            arr[e]=(int)(Math.random()*100);
        }
        Arrays.sort(arr);
        System.out.println("排序后：");
        for(int f=0;0<arr.length;f++){
            System.out.println(arr[f]);
        }




    }
}
